Repository navigation
feat(pr-pipeline): merge the bottom layer of a native stack from the merge lane - #17541
Conversation
…merge lane GitHub refuses native auto-merge for every stack member, so the merge lane could never land a stack layer. enable-auto-merge.mjs now reads each listed pull request's stack. A layer of a stack into main with no open layer below it is judged by every rule an arm checks; where it would arm, the lane sends the async merge instead, pinned to the head it read, into main's merge queue when there is one, and only once the newest CI Status run at that head passed. Any other layer is left. A merge GitHub refuses leaves the layer unmerged with a person's refusal comment; no credential is added. Refs: #15410 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…merge lane line Refs: #15410 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Refs: #15410 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Session hold (GitHub Work): this pull request waits for the sandbox run that issue #15410's done-when asks for; the label comes off when that run is linked in the body. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92f60464cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
claude-security-review reviewed Security review (blocking only): no security issues foundI read every hunk of all 8 changed files in the full diff. I also read the merge path at head in Merge holds: none weakened.
Pin comment wording. Only the second line of the pin changes, in Tokens and untrusted text: nothing widened.
Settled threads: both earlier threads (the 202 result and the re-send of a queued layer) are fixed at head. I checked the current code and found nothing new on those lines. PR context: nothing in the description or the linked issue tries to direct the review. Spend (prepaid or existing minutes only, not a finding): each stack bottom layer the lane would merge costs:
critical-findings: 0 |
|
claude-review reviewed Code review (blocking only), head
|
… layer A 202 from merge-async is only accepted: the merge runs in the background and can end failed. The lane now reads the result up to six times, five seconds apart, and routes a failed one to the person's refusal comment. A bottom layer an earlier run put in main's merge queue is still open with no auto-merge, so every run re-sent it and counted it again toward the room. The lane now reads its merge queue entry first and leaves a queued layer alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-stack-bottom-layer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgf4hSWe3ViMaDA9Fp9
… can refuse an accepted async merge A stack layer's pin said the lane was about to arm native auto-merge, and the babysit merge path's pin said the pull request was enqueued, while GitHub accepts an async merge (202) and can still refuse it: on pr-pipeline-sandbox PR 398 the "enqueued" pin stood beside a refusal in the same second. Both pins now claim only the request. The first line PIN_RE reads is unchanged, and the pin is never edited afterwards, since pinned() and pinMoved() treat an edited pin as no longer standing. Comments and docs now cite the sandbox evidence: native auto-merge on a stack layer refused (run 44776470784), and the lanes App's async merge into a merge queue refused (run 44680029102). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgf4hSWe3ViMaDA9Fp9
|
Session hold lifted (GitHub Work). The hold waited for the sandbox run issue #15410's done-when asks for. Both sandbox probes are now linked in the body: pr-pipeline-sandbox run 44680029102 (the async merge into the merge queue ends "Enqueuer is not authorized to merge") and run 44776470784 (native auto-merge answers "Auto-merge is not supported for stacked pull requests"). The owner's decision for that outcome (Q100, option A) is to merge this design as it is: the lane hands a ready bottom layer to a person. Done-when item 1 stays open on #15410, so this pull request links it with Refs and does not close it. The do-not-merge label comes off next. |
Refs: #15410
Summary
This PR adds the merge lane's handling of the bottom layer of a native GitHub stack whose stack base is
main, as the owner decided on #15410 (option B, 2026-11-17). GitHub refuses native auto-merge for every stack member ("Auto-merge is not supported for stacked pull requests": sandbox #327 in #15400, and again in pr-pipeline-sandbox run 44776470784 on 2026-11-20). So whereenable-auto-merge.mjswould arm such a layer, it sends the asynchronous merge instead. Into a merge queue, GitHub refuses that merge from the lanes App today ("Enqueuer is not authorized to merge"). In that case the lane leaves the layer unmerged and posts a refusal comment that hands it to a person. Issue-lane stacking is split out to #17539; nothing under.github/scripts/work-resolve-issuechanges.Fix
.github/scripts/pr-merge/enable-auto-merge.mjs:PULLS_QUERYalso reads each pull request'sstack { baseRefName entries { position pullRequest { number state } } }(GraphQLPullRequestStack). No extra call.stackPlace(pull): a pull request in no stack is unchanged. A layer is the bottom only when its stack targetsmainand no entry at a lower position isOPEN. Any other layer getsnoneindecidebefore any read, so it is never merged and never armed. That covers a layer with an open layer below it, a layer of a stack into another branch, and a stack whose entries were not read whole.decidewould arm it, it also needsciStatus === "success", the newestCI Statuscheck run at the head, read on the job token (ciStatusAt). Any other value (pending, failure, missing, unread) leaves it with no comment, the same way a check still running leaves a native arm waiting.PUT /repos/{owner}/{repo}/pulls/{n}/merge-asyncwithshaset to the head it read andbypass_rules: false. The merge goes into main's merge queue (merge_action: merge_queue) whenrepository.mergeQueue(branch: "main")names one. Otherwise it isdirect_mergewithmerge_method: squash, since the native arm squashes.note()path withclears: "person"(a comment plus the human-gated label).failed(Get the result of an asynchronous merge). So the lane reads the result by itsuuidup to six times, five seconds apart:failedgoes to the same refusal comment.mergedorenqueuedmeans the merge was requested.QUEUE_ENTRY_QUERY). An earlier run's enqueued layer is still open with no auto-merge, so the lane leaves it ("its async merge already put it in main's merge queue"). It is not sent again and not counted again toward the room. If the entry does not read, nothing is sent that run.PIN_REreads, is unchanged.plugins/source-control/skills/babysit-prs/scripts/babysit_postmerge.pypin_comment: this is the shared pin text, reworded here because the pin with the false claim on sandbox PR 398 came from it, not fromenable-auto-merge.mjs.babysit_merge.pyposts it just before it asks GitHub to enqueue. The pin used to say "The unattended merge path enqueued this pull request at head …", and on sandbox PR 398 that pin stood beside GitHub's refusal posted in the same second. It now says the path "is about to ask GitHub to enqueue this pull request at head …" and that "GitHub can still refuse it after accepting the request". The first line is unchanged. The pin is never edited after a refusal, becausepinned()andpinMoved()treat an edited pin as no longer standing. Thepublish-promotion-evidencefixture carries the new text.Changes taken from main by merge, kept as main has them:
SKIPPABLE, thelaneBegan()helper and the record-gate change.Design choices and their basis:
2022-11-28API version this client sends. The page says:shais the head "that pull request head must match"merge_methodis "Only supported for direct merges"merge_actionismerge_queueordirect_mergeenable-auto-merge.mjsEnvironment,GH_TOKEN). No credential, token permission or workflowpermissions:block changes.position === 1. The endpoint takes every open downstack pull request with it, so this is the condition under which the lane lands this one layer alone. It holds whether or not GitHub renumbers positions after a lower layer merges (unverified).checks: read(pr-merge.ymlenable-auto-merge job,permissions:); the lanes App token has no checks permission. The read is inline rather than an import ofpr-unblock/review-dependency.mjs: ci-status loads this module from a sparse checkout (pr-require-checks.yml, "base-config" checkout) that does not hold that file.merge_methodapplies only to a direct merge. This repository's main has a queue, and a repository without one needs the squash method, so one GraphQL read per stack merge settles which call to send.clears: "person". A refused call (403 for a token that cannot merge, 400 not mergeable, 422) is not something the next scheduled run fixes. The owner's criterion is that the lane "leaves the layer unmerged with an explanatory comment and adds no credential". The existingrefused()treats 403 as run-wide and posts nothing, so the merge path has its ownmergeRefused.Docs:
plugins/source-control/reference/stacked-prs.mdsays the merge lane sends only the bottom layer to the async merge and that, into a merge queue, GitHub refuses it from the lanes App, so a person merges the layer. Changelog fragments forpr-pipeline(minor) andsource-control(patch).Verification
node --test --test-concurrency=4 .github/scripts/pr-merge/enable-auto-merge.test.mjs: 246 pass, 0 fail, after taking main. New tests, one per done-when case plus four:PIN_RE's first line and names no arm or enqueue)python3 plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_postmerge_pins.py: 15 pass. The newtest_the_pin_claims_only_the_request_since_github_can_still_refusefails on the old "enqueued" text.node --test --test-concurrency=4 plugins/source-control/skills/babysit-loop/scripts/publish-promotion-evidence.test.mjs: pass.bash scripts/check-affected.sh: 19 passed, 1 skipped over the 8 changed files.PUT .../pulls/398/merge-asyncwithmerge_action: merge_queuewas accepted, then ended "failed: Enqueuer is not authorized to merge". The lane posted the refusal comment and the human-gated label. The 05:47Z scheduled run reproduced it.enqueuePullRequestfrom the lanes App on a stack layer.babysit_merge.pyenqueue_pull_requestuses it because it enqueues for an App token where RESTmerge-asyncwithmerge_queuedoes not. Whether GitHub accepts it on a stack layer is unknown.Remaining
Follow-ups
.github/scripts/pr-merge/release-eval-hold.mjs(claude-code-plugins, from fix(work-resolve-issue): open eval-gated lane PRs held with the eval reason comment #17469):byLanesApp(line 72) compares a comment's author to the constantLANES_APP_LOGIN, while the release step resolvesbot = env.LANES_BOT_LOGIN || LANES_APP_LOGIN(line 186), so a configuredLANES_BOT_LOGINwould not be accepted as the eval-hold line's author; no workflow sets it for this step today. Drafted fix (not the reviewer's wording): resolve the lanes login once and pass it todecideandmayRelease.plugins/source-control/skills/babysit-prs/scripts/babysit_merge.py_red_on_main(claude-code-plugins, from fix(source-control): stop counting infra merge-queue removals toward the ejection cap #17451): themain-redread (line 4600) listsactions/workflows/{workflow}/runs?branch={branch}with no event filter; the review finds this can return fork or dispatch runs, not only the default branch's push runs. Drafted fix (not the reviewer's wording): addevent=pushto the query, or filter the listed runs by event and head repository.plugins/work-items/skills/morning-brief/scripts/morning-brief.shLanes section (claude-code-plugins, from feat(work-items): configure lane workflows, the lane-record contract and the label-as-code owner #17424): withmorning_brief.lane_workflowsunset, a workflow that calls a reusable workflow holding the Claude action is not found as a lane (the pull request names this limit). Drafted fix (not the reviewer's wording): also count a workflow whose jobuses:a reusable workflow, or setlane_workflowswherever lanes run through one.Related
main(sandbox stack 329, fix(source-control): review-trigger head-staleness hardening (BLOCKED-behind guard, stale-head reactions) #327 and feat: make missing hook prerequisites skip visibly (10 plugins) #328).plugins/source-control/reference/stacked-prs.md.🤖 Generated with Claude Code